package com.hj.mapper;

import com.hj.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;

import javax.annotation.ManagedBean;
import java.util.List;
import java.util.Map;
@Mapper
public interface UserMapper {
    /**
     * 插入用户
     * @param user 用户数据
     * @return 返回插入的用户数据的id
     */
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert("INSERT INTO tb_user (username, password, gender, age, email, phone, address) " +
            "VALUES (#{username}, #{password}, #{gender}, #{age}, #{email}, #{phone}, #{address})")
    int insertUser(User user);
    /**
     * 查询所有
     * @return
     *//*
    List<User> selectAll();

    *//**
     * 按照id查询
     * @param uid
     * @return
     *//*
    User selectById(int uid);

    *//**
     * 条件查询
     *  *参数接收
     *      1.散装参数：如果方法中有多个参数，需要使用@Parm（“SQL参数占位符名称”）
     *      2.对象参数:对象的属性名称要和擦拿书占位符名称一致
     *      3.map集合参数
     * @param uname
     * @param address
     * @return
     *//*
    //List<User> selectByCondition(@Param("uname") String uname,@Param("address") String address);
    //List<User> selectByCondition(User user);
    List<User> selectByCondition(Map map);

    *//**
     * 单条件动态查询
     * @param user
     * @return
     *//*
    List<User> selectByConditionSingle(User user);


    *//**
     * 添加
     *//*
    void add(User user);
    User repeat( @Param("username") String username);

    // 验证 username 是否重复
    // 防止查询不到值为空，用Integer
    public Integer userNameValidate(@Param("value")String value);*/
}
